{extend name="../../admin/view/main"}
{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <ul class="layui-tab-title">
        <li class="layui-this" data-open="{:url('index')}">领用管理</li>
    </ul>
    <div class="layui-tab-content" style="text-align: center;padding: 13%">
        <div style="padding-bottom: 5%;font-size: 28px">商品出库</div>
        <input class="layui-input" id="test" style="color: #000;border-color:#000;height: 60px;font-size: 20px " type="text" value="" autofocus="autofocus" placeholder="扫码枪扫码前，请将在鼠标点击该输入框后扫码">
    </div>
    <script>
        form.render()
        setTimeout("$('#test').focus()",500);
        $('#test').bind('input propertychange', function(res) {
            var value = $('#test').val()
            var url = "#data/control.lists/ex_data_list?spm={$_GET['spm']}&userId="+value
            if(value.length === 5){
                layer.open({
                    type: 2,
                    title: '列表',
                    area: ['80%', '90vh'],
                    fixed: true, //不固定
                    maxmin: false,
                    content: url,
                    btn: ['获取选中的', '关闭'],
                    btnclass: ['btn btn-primary', 'btn btn-danger'],
                    yes: function (index, layero) {
                        $('#test').val("")
                        var storageList = localStorage.getItem(value)
                        //ajax 提交
                        keyup_submit(storageList,value)
                        layer.msg('加载中', {
                            icon: 16
                            ,shade: 0.01
                        });
                        // parent.layer.close(index);
                    }, cancel: function () {
                        return true;
                    },end : function() {
                        $('#test').val("")
                    }

                });



            }
        });
        function keyup_submit(data,userId){
            $.ajax({
                type: 'POST',
                url: "{:url('addPlanCollect')}",
                data: {
                    admin_id: userId,
                    plan_list: data
                },
                dataType: "json",
                success: function (data) {
                    console.log(data)
                    if(data.code === 1){
                        localStorage.removeItem(userId);
                        layer.msg(data.info, {icon: 1},function () {
                            layer.msg(data.info,{time: 2000, icon:1})
                            parent.location.reload();
                        });
                    }else{
                        layer.msg(data.info,{time: 2000, icon:2})
                    }
                }
            });

        }
    </script>
</div>
{/block}